package com.finchina.myview.shader;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.SweepGradient;
import android.util.AttributeSet;
import android.view.View;

/**
 * 作者：黄赛赛 on 2015/9/21 09:21
 *http://blog.csdn.net/aigestudio/article/details/41799811
 * @version V1.0
 * @Description: ${todo}()
 */
public class SweepGradientShaderView extends View{

    Paint paint;
    public SweepGradientShaderView(Context context, AttributeSet attrs) {
        super(context, attrs);
        paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
//        paint.setShader(new )
    }

    @Override
    protected void onDraw(Canvas canvas) {
//        super.onDraw(canvas);
        int screenX = getWidth();
        int screenY = getHeight();
        paint.setShader(  new SweepGradient(screenX/2, screenY/2, Color.RED, Color.YELLOW));
        canvas.drawRect(0,0,screenX,screenY, paint);
    }
}
